from django.db import models
import urllib2, feedparser
from array import *
#proxy = urllib2.ProxyHandler( {"http":"http://wwwcache.dcs.gla.ac.uk:8080/"} )
#bbcfeed = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml', handlers = [proxy])
#request = 'http://feeds.bbci.co.uk/news/rss.xml'
# Create your models here.

#Return rss feed for a given RSS link
def getfeed(request):
	#Needed to bypass University proxy
	proxy = urllib2.ProxyHandler( {"http":"http://wwwcache.dcs.gla.ac.uk:8080/"} )
	feed = feedparser.parse(request, handlers = [proxy])
	return feed

#Constructs rss FEEDs dictionary for a given RSS links in array
def getfeeds(requestarray):
	#Needed to bypass University proxy
	proxy = urllib2.ProxyHandler( {"http":"http://wwwcache.dcs.gla.ac.uk:8080/"} )
	feeds = {}
	c = 0
	for singlefeed in requestarray:
		feed = feedparser.parse(singlefeed, handlers = [proxy])
		feeds[c] = feed
		c = c +1
	print feeds[0]
	return feeds

